/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Pacotes;


import Estruturas.Manipuladores;
import Opcoes.Conexoes;
import Opcoes.Pacotes;

public class Query extends Header {

    byte[] speed;
    String criteria;

    public Query (String query)
    {
        super((byte) Pacotes.PAYLOAD_OF_QUERY, 2+query.length()+1);
        this.speed = new byte[2];
        this.criteria = query + (char)0;
        this.speed = Manipuladores.intToByteArray(Conexoes.DEFAULT_SPEED);
    }

    public String make ()
    {
        return makeHeader() + (char)speed[0] + (char)speed[1] + criteria;
    }

    public String getCriteria() {
        return String.format("%s", criteria);
    }

    public void setCriteria(String criteria) {
        this.criteria = criteria + (char)0;
    }

    public int getSpeed() {
        return Manipuladores.byteArrayToShort(speed, 0);
    }

    public void setSpeed(short speed) {
        this.speed = Manipuladores.ShortToByteArray(speed);
    }





}
